<?php 
class Employee extends MY_Controller {
    
    function __construct() {
        parent::__construct();
        
		$this->load->library('form_validation');
		$this->load->model('user_model', '', TRUE);
        $this->load->model('society_model', '', TRUE);
        $this->load->model('association_model', '', TRUE);
        $this->load->model('teacher_model', '', TRUE);
        
        $this->load->library('col_pro_data');
    }
    
	/**
	 * 社联成员查询
	 */
 	function manage($param = "0-0-0-0-0") {
 		
		$url_array = explode("-", $param);
		$data['url_array'] = $url_array;
		
		$condition = $this->_get_condition($url_array);
		$data['search_employee_count'] = $this->association_model->search_by_condition($condition, "", TRUE);
		
		//---------------------------------- 分页开始 ------------------------------------//
        $this->load->library('pagination');
        $config['base_url'] = BACKEND_ASSOCIATION_EMPLOYEE_SEARCH_PATH . '/' . $param;
        $config['total_rows'] = $data['search_employee_count'];
        $config['uri_segment'] = 6;
        $config['per_page'] = PER_PAGE;
        //$config['num_links'] = 5;  //页码链接偏移量
        $config['first_link'] = '首页';
        $config['last_link'] = '尾页';
        $config['next_link'] = '下一页';
        $config['prev_link'] = '上一页';
        $config['anchor_class'] = "class='anchor_button' style='font-size: 80%;'"; 
        //$config['suffix'] = "#pagefocus";
        
        $this->pagination->initialize($config);

		$condition['per_page'] = PER_PAGE;
		$condition['offset'] = $this->uri->segment(6);
		
		$data['search_employee'] = $this->association_model->search_by_condition($condition);
		//---------------------------------- 分页结束 ------------------------------------//
		//echo "<pre>";
		//print_r($data['search_employee']);
		//return ;
		
		////////////////已登陆用户信息绑定/////////////
		$data['user_info'] = $this->login_user_info();
		
		////////////////用户后台侧栏信息绑定/////////////
		$data['sidebar_info'] = $this->sidebar_info();
		
		$this->load->view('backend/association/manage_employee', $data);
 	}
 	
	function _get_condition($url_array) {
        
		$condition['confirm_FLAG'] = ASSOCIATION_VERIFY_PASS;
		$condition['function_FLAG'] = NOT_FUNCTION;
		
		if ($url_array[0]) {
			$condition['name'] = urldecode($url_array[0]);
		}
		if ($url_array[1] != 0) {
			$condition['gender'] = $url_array[1];
		}
    	if ($url_array[2] != 0) {
			$condition['category'] = $url_array[2];
		}
		if ($url_array[3] != 0) {
			$condition['col'] = $url_array[3];
		}
		if ($url_array[4] != 0) {
			$condition['pro'] = $url_array[4];
		}
		
		//echo "<pre>";
		//print_r($condition);
		//return ;
		
		if (!empty($condition)) {
			
			return $condition;
		}
    }
    
    function ajax_get_employee_info() {
    	$employee_id = $this->input->post("employee_id");
    	
    	$condition['association_id'] = $employee_id;
    	$data = $this->association_model->search_by_condition($condition, TRUE);
    	
    	//echo "<pre>";
    	//print_r($data);
    	//return ;
    	$this->output->set_output(json_encode($data));
    }

}